// inheritance
function extend(child, parent) {
  var f = function() {};
  f.prototype = parent.prototype;
  child.prototype = new f();
  child.prototype.constructor = child;
  child.base = parent.prototype;
}
function extend2(child, parent) {
  var c = child.prototype;
  var p = parent.prototype;
  for (var i in p) {
    c[i] = p[i];
  }
  c.base = p;
}
function deepCopy(child, parent){
  var child = child || {};
  for (var i in parent) {
    if (typeof parent[i] === 'object') {
      child[i] = (parent[i].constructor === Array) ? [] : {};
      deepCopy(child[i], parent[i]);
    } else {
      child[i] = parent[i];
    }
  }
  return child;
}
function isInRect(x,y,recX,recY,recW,recH)
{
  var farX = recX+recW;
  var farY = recY+recH;
  if( x<recX||x>farX||y<recY||y>farY)
    return false;
  return true;
}

var gewUniqueNumber = 0;
function getUniqueNumber()
{
  gewUniqueNumber++;
  return gewUniqueNumber;
}

// Array utils
function getOffsetInArray(element,array)
{
  var len = array.length;
  for(var i=0;i<len;i++)
    if(element==array[i])
      return i;
  return -1;
}
function isInArray(element,array)
{
  var len = array.length;
  for(var i=0;i<len;i++)
    if(element==array[i])
      return true;
  return false;
}
function removeFromArray(element,array)
{
  var len = array.length;
  for(var i=0;i<len;i++)
    if(element==array[i])
    {
      array.splice(i,1);
      return true;
    }
  return false;
}
